*=========================================================================*
*	Gender gap in AI skill premiums: belief updating and behavioral responses
*	
*	4/20/2025
*	-------
*	Main Experiment Figures

*=========================================================================*
clear all
set more off

*cd
cd "D:\PhD\Research\AI_gender_gap"
global path="D:\PhD\Research\AI_gender_gap"
global data = "${path}\data"
global table = "${path}\results\table"
global figure = "${path}\results\figure"

graph set window fontface     "Times New Roman"
graph set window fontfacesans "宋体"
set scheme s1color


use "${data}\clean_data.dta",replace

global demo female age white married parental_status college fulltime low middle
* ------------------------------------------------------------------------------
*                       fig.1
* ------------------------------------------------------------------------------	  
			  
			  
ttest ai_premium_f_p=ai_premium_m_p 
local p_ttest = r(p)
* Format p-values for display
local p_ttest_f = string(`p_ttest', "%9.4f")
twoway (histogram ai_premium_f_p , start(-24) width(4) fraction fcolor(maroon%50) lcolor(none)) ///
       (histogram ai_premium_m_p , start(-16) width(4) fraction fcolor(navy%40) lcolor(navy)) ///
       (scatteri 0 0 0.15 0, recast(line) lcolor(blue) lpattern(shortdash) lwidth(medium)) /// 在 x=0 处从 y=0 到 y=0.34 绘制垂直线
       (scatteri 0 8 0.15 8, recast(line) lcolor(red) lpattern(shortdash) lwidth(medium)) /// 在 x=8 处从 y=0 到 y=0.34 绘制垂直线
	   (scatteri 0 39.4 0.15 39.4, recast(line) lcolor(blue) lpattern(solid) lwidth(medium)) ///
	   (scatteri 0 37.1 0.15 37.1, recast(line) lcolor(red) lpattern(solid) lwidth(medium))  ///
	   (scatteri 0.155 37.1 0.155 39.4, recast(line) lcolor(black) lwidth(medium)) /// 在 x=8 处从 y=0 到 y=0.34 绘制垂直线
	   (scatteri 0.155 37.1 0.153 37.1, recast(line) lcolor(black) lwidth(medium)) ///
	   (scatteri 0.155 39.4 0.153 39.4, recast(line) lcolor(black) lwidth(medium)),	   ///
	  legend(order(1 "Predicted AI skill premiums for women" 2 "Predicted AI skill premiums for men") size(small)) ///
       title("") ytitle("") ///
	   graphregion(color(white) lcolor(none)) plotregion(lcolor(none)) ///
       xlabel(-30(10)100) text(0.155 42 "{it:p} < .001", place(e) size(small)) ///
	   text(0.157 38.25 "***",size(small))
	   
       graph export "${figure}/figure1.png", replace 
	   graph save "${figure}/figure1.gph", replace	
	   
	   
* ------------------------------------------------------------------------------
*                       fig.2
* ------------------------------------------------------------------------------	

preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg usai_skill_premium_f Female_only Male_only Both ai_premium_f_p ai_premium_m_p $demo if female==1, vce(r)
quietly eststo Male: reg usai_skill_premium_f Female_only Male_only Both ai_premium_f_p ai_premium_m_p $demo if female==0, vce(r)

* Step 1: Perform the lincom tests and store raw p-values
lincom Female_only - Male_only
local p1 = r(p)          // p-value for Female_only vs Male_only

lincom Female_only - Both
local p2 = r(p)          // p-value for Female_only vs Both

lincom Male_only - Both
local p3 = r(p)          // p-value for Male_only vs Both

* Step 2: Holm-Bonferroni adjustment (manual for 3 p-values)

local alpha = 0.05
local k     = 3

* Display raw p-values
di _n "Raw (unadjusted) p-values:"
di "  Female_only vs Male_only : " %9.4f `p1'
di "  Female_only vs Both      : " %9.4f `p2'
di "  Male_only   vs Both      : " %9.4f `p3'

* Sort the three p-values manually (no macros needed for scalars)
tempname sp1 sp2 sp3          // temporary scalars for sorted p-values

* Find min, max, and middle
scalar `sp1' = min(`p1', `p2', `p3')                  // smallest
scalar `sp3' = max(`p1', `p2', `p3')                  // largest
scalar `sp2' = `p1' + `p2' + `p3' - `sp1' - `sp3'     // middle value

* Display sorted raw p-values (for clarity)
di _n "Sorted raw p-values:"
di "  Smallest: " %9.4f `sp1'
di "  Middle:   " %9.4f `sp2'
di "  Largest:  " %9.4f `sp3'

* Holm step-down procedure
di _n "Holm-Bonferroni adjusted results (alpha = 0.05):"

local thresh1 = `alpha' / `k'
if `sp1' <= `thresh1' {
    di "  Smallest p = " %9.4f `sp1' " <= " %9.4f `thresh1' " → significant"
    
    local thresh2 = `alpha' / (`k'-1)
    if `sp2' <= `thresh2' {
        di "  Second smallest p = " %9.4f `sp2' " <= " %9.4f `thresh2' " → significant"
        
        local thresh3 = `alpha' / (`k'-2)
        if `sp3' <= `thresh3' {
            di "  Largest p = " %9.4f `sp3' " <= " %9.4f `thresh3' " → significant"
        }
        else {
            di "  Largest p = " %9.4f `sp3' " > " %9.4f `thresh3' " → not significant (procedure stops)"
        }
    }
    else {
        di "  Second smallest p = " %9.4f `sp2' " > " %9.4f `thresh2' " → not significant (and all remaining)"
    }
}
else {
    di "  Smallest p = " %9.4f `sp1' " > " %9.4f `thresh1' " → not significant (all tests not significant)"
}

* Bonus: Compute commonly reported adjusted p-values (p * adjustment factor, capped at 1)
scalar adj_p1 = min(`sp1' * `k', 1)
scalar adj_p2 = min(`sp2' * (`k'-1), 1)
scalar adj_p3 = min(`sp3' * 1, 1)

di _n "Commonly reported adjusted p-values (Holm style):"
di "  Smallest: " %9.4f adj_p1
di "  Middle:   " %9.4f adj_p2
di "  Largest:  " %9.4f adj_p3

*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore all_Female
parmest, norestore saving(all_female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

estimates restore all_Male
parmest, norestore saving(all_male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use all_female_results.dta, clear
gen gender = "Female"
keep if parm == "treat"
save all_female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace

use all_male_results.dta, clear
gen gender = "Male"
keep if parm == "treat"
save all_male_clean.dta, replace

*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta
append using all_female_clean.dta
append using all_male_clean.dta
*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"
replace group = 7 if gender == "Female" & parm == "treat"
replace group = 8 if gender == "Male" & parm == "treat"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)), /// 
    /// (scatteri -25 5 -25 7, recast(line) lcolor(black) lwidth(vthin)) /// 
    /// (scatteri -25 5 -24.5 5, recast(line) lcolor(black) lwidth(vthin)) /// 
    /// (scatteri -25 7 -24.5 7, recast(line) lcolor(black) lwidth(vthin)), /// 
    xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5)) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(5(-5)-35, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Predicted AI skill premiums for U.S. women" ,size(vlarge)) /// 
    legend(off) /// 
    /// text(-25.5 6 "*") /// 
	text(7 -0.2 "{bf:a}", placement(nw) size(vlarge) ) ///  // Added bold 'a' in top-left
    graphregion(color(white)) plotregion(color(white))
graph save "${figure}/coefplot/uspremium1_grouped-v3.gph", replace
	
restore


preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg usai_skill_premium_m Female_only Male_only Both ai_premium_f_p ai_premium_m_p $demo if female==1, vce(r)
quietly eststo Male: reg usai_skill_premium_m Female_only Male_only Both ai_premium_f_p ai_premium_m_p $demo if female==0, vce(r)

* Step 1: Perform the lincom tests and store raw p-values
lincom Female_only - Male_only
local p1 = r(p)          // p-value for Female_only vs Male_only

lincom Female_only - Both
local p2 = r(p)          // p-value for Female_only vs Both

lincom Male_only - Both
local p3 = r(p)          // p-value for Male_only vs Both

* Step 2: Holm-Bonferroni adjustment (manual for 3 p-values)

local alpha = 0.05
local k     = 3

* Display raw p-values
di _n "Raw (unadjusted) p-values:"
di "  Female_only vs Male_only : " %9.4f `p1'
di "  Female_only vs Both      : " %9.4f `p2'
di "  Male_only   vs Both      : " %9.4f `p3'

* Sort the three p-values manually (no macros needed for scalars)
tempname sp1 sp2 sp3          // temporary scalars for sorted p-values

* Find min, max, and middle
scalar `sp1' = min(`p1', `p2', `p3')                  // smallest
scalar `sp3' = max(`p1', `p2', `p3')                  // largest
scalar `sp2' = `p1' + `p2' + `p3' - `sp1' - `sp3'     // middle value

* Display sorted raw p-values (for clarity)
di _n "Sorted raw p-values:"
di "  Smallest: " %9.4f `sp1'
di "  Middle:   " %9.4f `sp2'
di "  Largest:  " %9.4f `sp3'

* Holm step-down procedure
di _n "Holm-Bonferroni adjusted results (alpha = 0.05):"

local thresh1 = `alpha' / `k'
if `sp1' <= `thresh1' {
    di "  Smallest p = " %9.4f `sp1' " <= " %9.4f `thresh1' " → significant"
    
    local thresh2 = `alpha' / (`k'-1)
    if `sp2' <= `thresh2' {
        di "  Second smallest p = " %9.4f `sp2' " <= " %9.4f `thresh2' " → significant"
        
        local thresh3 = `alpha' / (`k'-2)
        if `sp3' <= `thresh3' {
            di "  Largest p = " %9.4f `sp3' " <= " %9.4f `thresh3' " → significant"
        }
        else {
            di "  Largest p = " %9.4f `sp3' " > " %9.4f `thresh3' " → not significant (procedure stops)"
        }
    }
    else {
        di "  Second smallest p = " %9.4f `sp2' " > " %9.4f `thresh2' " → not significant (and all remaining)"
    }
}
else {
    di "  Smallest p = " %9.4f `sp1' " > " %9.4f `thresh1' " → not significant (all tests not significant)"
}

* Bonus: Compute commonly reported adjusted p-values (p * adjustment factor, capped at 1)
scalar adj_p1 = min(`sp1' * `k', 1)
scalar adj_p2 = min(`sp2' * (`k'-1), 1)
scalar adj_p3 = min(`sp3' * 1, 1)

di _n "Commonly reported adjusted p-values (Holm style):"
di "  Smallest: " %9.4f adj_p1
di "  Middle:   " %9.4f adj_p2
di "  Largest:  " %9.4f adj_p3

*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore all_Female
parmest, norestore saving(all_female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

estimates restore all_Male
parmest, norestore saving(all_male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use all_female_results.dta, clear
gen gender = "Female"
keep if parm == "treat"
save all_female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace

use all_male_results.dta, clear
gen gender = "Male"
keep if parm == "treat"
save all_male_clean.dta, replace

*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta
append using all_female_clean.dta
append using all_male_clean.dta
*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"
replace group = 7 if gender == "Female" & parm == "treat"
replace group = 8 if gender == "Male" & parm == "treat"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)) /// 
	(scatteri -30 5 -30 7, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -30 5 -29.5 5, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -30 7 -29.5 7, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -32 1 -32 2, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -32 1 -31.5 1, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -32 2 -31.5 2, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -34 1 -34 3, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -34 1 -33.5 1, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -34 3 -33.5 3, recast(line) lcolor(black) lwidth(vthin)), ///
    xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5)) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(5(-5)-35, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Predicted AI skill premiums for U.S. men",size(vlarge)) /// 
    legend(off) /// 
	text(-30.5 6 "*") ///
	text(-32.5 1.5 "*") ///
	text(-34.5 2 "*") ///
	text(7 -0.2 "{bf:b}", placement(nw) size(vlarge) ) ///  // Added bold 'a' in top-left
    graphregion(color(white)) plotregion(color(white))	
	
	
/*
	(scatteri -6 2 -6 6, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -6 2 -6.5 2, recast(line) lcolor(black) lwidth(vthin)) ///
	(scatteri -6 6 -6.5 6, recast(line) lcolor(black) lwidth(vthin))
*/
*-----------------------------------------------------------
* Step 7: 保存图形
*-----------------------------------------------------------
graph save "${figure}/coefplot/uspremium2_grouped-v3.gph", replace

restore



preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==1,r

reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==1,r
lincom (_cons+Female_only)-(_cons)

quietly eststo Male: reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==0,r

* Step 1: Perform the lincom tests and store raw p-values
lincom Female_only - Male_only
local p1 = r(p)          // p-value for Female_only vs Male_only

lincom Female_only - Both
local p2 = r(p)          // p-value for Female_only vs Both

lincom Male_only - Both
local p3 = r(p)          // p-value for Male_only vs Both

* Step 2: Holm-Bonferroni adjustment (manual for 3 p-values)

local alpha = 0.05
local k     = 3

* Display raw p-values
di _n "Raw (unadjusted) p-values:"
di "  Female_only vs Male_only : " %9.4f `p1'
di "  Female_only vs Both      : " %9.4f `p2'
di "  Male_only   vs Both      : " %9.4f `p3'

* Sort the three p-values manually (no macros needed for scalars)
tempname sp1 sp2 sp3          // temporary scalars for sorted p-values

* Find min, max, and middle
scalar `sp1' = min(`p1', `p2', `p3')                  // smallest
scalar `sp3' = max(`p1', `p2', `p3')                  // largest
scalar `sp2' = `p1' + `p2' + `p3' - `sp1' - `sp3'     // middle value

* Display sorted raw p-values (for clarity)
di _n "Sorted raw p-values:"
di "  Smallest: " %9.4f `sp1'
di "  Middle:   " %9.4f `sp2'
di "  Largest:  " %9.4f `sp3'

* Holm step-down procedure
di _n "Holm-Bonferroni adjusted results (alpha = 0.05):"

local thresh1 = `alpha' / `k'
if `sp1' <= `thresh1' {
    di "  Smallest p = " %9.4f `sp1' " <= " %9.4f `thresh1' " → significant"
    
    local thresh2 = `alpha' / (`k'-1)
    if `sp2' <= `thresh2' {
        di "  Second smallest p = " %9.4f `sp2' " <= " %9.4f `thresh2' " → significant"
        
        local thresh3 = `alpha' / (`k'-2)
        if `sp3' <= `thresh3' {
            di "  Largest p = " %9.4f `sp3' " <= " %9.4f `thresh3' " → significant"
        }
        else {
            di "  Largest p = " %9.4f `sp3' " > " %9.4f `thresh3' " → not significant (procedure stops)"
        }
    }
    else {
        di "  Second smallest p = " %9.4f `sp2' " > " %9.4f `thresh2' " → not significant (and all remaining)"
    }
}
else {
    di "  Smallest p = " %9.4f `sp1' " > " %9.4f `thresh1' " → not significant (all tests not significant)"
}

* Bonus: Compute commonly reported adjusted p-values (p * adjustment factor, capped at 1)
scalar adj_p1 = min(`sp1' * `k', 1)
scalar adj_p2 = min(`sp2' * (`k'-1), 1)
scalar adj_p3 = min(`sp3' * 1, 1)

di _n "Commonly reported adjusted p-values (Holm style):"
di "  Smallest: " %9.4f adj_p1
di "  Middle:   " %9.4f adj_p2
di "  Largest:  " %9.4f adj_p3
*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)) /// 
	(scatteri -14 1 -14 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
	(scatteri -14 1 -13.7 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
	(scatteri -14 2 -13.7 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
	(scatteri -16 1 -16 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
	(scatteri -16 1 -15.7 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
	(scatteri -16 3 -15.7 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)),  ///  
	xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5)) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(-20(5)10, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Perceived gender gap",size(vlarge)) /// 
    legend(order(2 "Female only" 4 "Male only" 6 "Info both") pos(4) col(1) region(lcolor(none) lwidth(none)) ring(0) size(large)) /// 
    text(-14.5 1.5 "**") ///
	text(-16.5 2 "***") ///
	text(11.5 -0.2 "{bf:c}", placement(nw) size(vlarge) ) ///  // Added bold 'a' in top-left
    graphregion(color(white)) plotregion(color(white))	

graph save "${figure}/coefplot/ai_gendergap.gph", replace
graph export "${figure}/coefplot/ai_gendergap.png", replace

restore



graph combine "${figure}/coefplot/uspremium1_grouped-v3.gph" ///
              "${figure}/coefplot/uspremium2_grouped-v3.gph" ///
			  "${figure}/coefplot/ai_gendergap.gph", ///
			  row(1) col(3) ///
			  note("Adjusted p-values using Holm-Bonferroni method for multiple comparisons", span size(medium)) ///
              title("",size(medlarge)) ///
			xsize(12) ysize(4)
				
graph export "${figure}/coefplot/figure2.png", replace width(7000) height(2000)  		




* ------------------------------------------------------------------------------
*                       fig.3
* ------------------------------------------------------------------------------

preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg zee_ai_competitive Female_only Male_only Both ai_premium_f ai_premium_m ai_competitive_pre $demo if female==1,r
quietly eststo Male: reg zee_ai_competitive Female_only Male_only Both ai_premium_f ai_premium_m ai_competitive_pre $demo if female==0,r

lincom Female_only-Male_only
lincom Female_only-Both
lincom Male_only-Both
*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)), ///
    xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5) ) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(0.4(-0.2)-0.8, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Makes me more competitive",size(vlarge)) /// 
    legend(off) /// 
		 text(0.5 -0.2 "{bf:a}", placement(nw) size(vlarge) ) /// 
    graphregion(color(white)) plotregion(color(white))	

graph save "${figure}/coefplot/ai_competitive.gph", replace

restore


preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg zee_ai_employment_opp Female_only Male_only Both ai_premium_f ai_premium_m ai_employment_opportunities_pre $demo if female==1,r
quietly eststo Male: reg zee_ai_employment_opp Female_only Male_only Both ai_premium_f ai_premium_m ai_employment_opportunities_pre $demo if female==0,r

lincom Female_only-Male_only
lincom Female_only-Both
lincom Male_only-Both

*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)) /// 
	(scatteri -0.6 1 -0.6 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) /// 
(scatteri -0.6 1 -0.58 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
(scatteri -0.6 2 -0.58 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)), ///
    xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5)) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(0.4(-0.2)-0.8, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Gives me more employment opportunities",size(vlarge)) /// 
    legend(off) /// 
         text(-0.63 1.5 "*")  /// 
		 text(0.5 -0.2 "{bf:b}", placement(nw) size(vlarge) ) /// 
    graphregion(color(white)) plotregion(color(white))	

graph save "${figure}/coefplot/ai_employment.gph", replace

restore



preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg zee_ai_salary_opportunities Female_only Male_only Both ai_premium_f ai_premium_m ai_salary_opportunities_pre $demo if female==1,r
quietly eststo Male: reg zee_ai_salary_opportunities Female_only Male_only Both ai_premium_f ai_premium_m ai_salary_opportunities_pre $demo if female==0,r

lincom Female_only-Male_only
lincom Female_only-Both
lincom Male_only-Both


*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)), /// 
///(scatteri -0.52 1 -0.52 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) /// 
///(scatteri -0.52 1 -0.5 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
///(scatteri -0.52 2 -0.5 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))   ///
///(scatteri -0.42 5 -0.42 6, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  
///(scatteri -0.42 5 -0.4 5, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  
///(scatteri -0.42 6 -0.4 6, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)), ///
    xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5)) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(0.4(-0.2)-0.8, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Enables me to earn a higher salary",size(vlarge)) /// 
    legend(order(2 "Female only" 4 "Male only" 6 "Info both") pos(4) col(1) region(lcolor(none) lwidth(none)) ring(0)  size(large)) /// 
         /// text(-0.55 1.5 "*")  /// // 在横线上方添加星号
		 /// text(-0.45 5.5 "*")   /// 
		 text(0.5 -0.2 "{bf:c}", placement(nw) size(vlarge) ) /// 
    graphregion(color(white)) plotregion(color(white))	


graph save "${figure}/coefplot/ai_salary.gph", replace

restore


graph combine "${figure}/coefplot/ai_competitive.gph" ///
              "${figure}/coefplot/ai_employment.gph" ///
              "${figure}/coefplot/ai_salary.gph", ///
              rows(1) cols(3) ///
			  note("Adjusted p-values using Holm-Bonferroni method for multiple comparisons", span size(medium)) ///
              title("", size(medlarge)) ///
			xsize(12) ysize(4)


graph export "${figure}/coefplot/figure3.png", replace width(7000) height(2000) 		


* ------------------------------------------------------------------------------
*                       fig.4
* ------------------------------------------------------------------------------

preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg zee_ai_willingness Female_only Male_only Both ai_premium_f ai_premium_m ai_willingness_pre $demo  if female==1, vce(r)
quietly eststo Male: reg zee_ai_willingness Female_only Male_only Both ai_premium_f ai_premium_m ai_willingness_pre $demo  if female==0, vce(r) 

lincom Female_only-Male_only
lincom Female_only-Both
lincom Male_only-Both
*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)), ///
    xlabel( 2 `"Female participants"' 6 `"Male participants"', labsize(large) ) /// 
    xscale(range(0.5 7.5) ) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(0.4(-0.2)-0.8, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Willing to use AI",size(vlarge)) /// 
    legend(off) /// 
	text(0.5 -0.2 "{bf:a}", placement(nw) size(vlarge) ) /// 
    graphregion(color(white)) plotregion(color(white))	

graph save "${figure}/coefplot/ai_willingtouse.gph", replace

restore


preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg zee_ai_sub Female_only Male_only Both ai_premium_f ai_premium_m ai_subscription_willingness_pre  $demo if female==1, vce(r)
quietly eststo Male: reg zee_ai_sub Female_only Male_only Both ai_premium_f ai_premium_m ai_subscription_willingness_pre $demo if female==0, vce(r) 

lincom Female_only-Male_only
lincom Female_only-Both
lincom Male_only-Both
*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)) /// 
	///(scatteri -0.6 1 -0.6 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
	///(scatteri -0.6 1 -0.58 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
	///(scatteri -0.6 2 -0.58 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))   ///  
	(scatteri -0.7 2 -0.7 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  // 主横线
	(scatteri -0.7 2 -0.68 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
	(scatteri -0.7 3 -0.68 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)), ///
	xlabel( 2 `"Female participants"' 6 `"Male participants"' , labsize(large)) /// 
    xscale(range(0.5 7.5) ) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(0.4(-0.2)-0.8, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Willing to subscribe paid AI tools",size(vlarge)) /// 
    legend(off) /// 
    /// text(-0.64 1.5 "*") /// // 在横线上方添加星号
	text(-0.74 2.5 "*") ///
	text(0.5 -0.2 "{bf:b}", placement(nw) size(vlarge) ) /// 
    graphregion(color(white)) plotregion(color(white))	

graph save "${figure}/coefplot/ai_subscribe.gph", replace
	 
restore


preserve
*-----------------------------------------------------------
* Step 1: 回归模型并保存
*-----------------------------------------------------------
quietly eststo Female: reg register Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==1,r
*test Female_only=Male_only
*lincom Female_only-Male_only
quietly eststo Male: reg register Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==0,r


*-----------------------------------------------------------
* Step 2: 提取系数为数据集（需要安装 parmest）
*-----------------------------------------------------------
estimates restore Female
parmest, norestore saving(female_results.dta, replace)

estimates restore Male
parmest, norestore saving(male_results.dta, replace)

*-----------------------------------------------------------
* Step 3: 清洗并添加标签
*-----------------------------------------------------------
use female_results.dta, clear
gen gender = "Female"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save female_clean.dta, replace

use male_results.dta, clear
gen gender = "Male"
keep if parm == "Female_only" | parm == "Male_only" | parm == "Both"
save male_clean.dta, replace


*-----------------------------------------------------------
* Step 4: 合并两个性别的结果
*-----------------------------------------------------------
use female_clean.dta, clear
append using male_clean.dta

*-----------------------------------------------------------
* Step 5: 创建绘图变量（横轴分组）
*-----------------------------------------------------------
gen group = .
replace group = 1 if gender == "Female" & parm == "Female_only"
replace group = 2 if gender == "Female" & parm == "Male_only"
replace group = 3 if gender == "Female" & parm == "Both"
replace group = 4 if gender == "Male" & parm == "Female_only"
replace group = 5 if gender == "Male" & parm == "Male_only"
replace group = 6 if gender == "Male" & parm == "Both"

*-----------------------------------------------------------
* Step 6: 绘图（twoway scatter + rcap）
*-----------------------------------------------------------

*drop xpos
* Create a new variable for shifted group positions
gen xpos = group

* Adjust the xpos variable to increase the distance between group 3 and group 4
replace xpos = xpos + 1 if group == 4 | group == 5 | group == 6

twoway ///
    (rcap min95 max95 xpos if group == 1, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 1, msymbol(circle) mcolor(maroon) ) /// 
    (rcap min95 max95 xpos if group == 2, lcolor(navy)) /// 
    (scatter estimate xpos if group == 2, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 3, lcolor(orange)) /// 
    (scatter estimate xpos if group == 3, msymbol(S) mcolor(orange)) /// 
    (rcap min95 max95 xpos if group == 4, lcolor(maroon)) /// 
    (scatter estimate xpos if group == 4, msymbol(circle) mcolor(maroon)) /// 
    (rcap min95 max95 xpos if group == 5, lcolor(navy)) /// 
    (scatter estimate xpos if group == 5, msymbol(T) mcolor(navy)) /// 
    (rcap min95 max95 xpos if group == 6, lcolor(orange)) /// 
    (scatter estimate xpos if group == 6, msymbol(S) mcolor(orange)), /// 
	///(scatteri -0.22 1 -0.22 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
	///(scatteri -0.22 1 -0.21 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
	///(scatteri -0.22 2 -0.21 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)),  ///  
	xlabel( 2 `"Female participants"' 6 `"Male participants"', labsize(large) ) /// 
    xscale(range(0.5 7.5)) ///   // Adjusted for better spacing
    yline(0, lcolor(gs10) lpattern(dash)) /// 
    ylabel(0.2(-0.2)-0.4, angle(0)) /// 
    ytitle("Average treatment effect",size(medium)) /// 
    xtitle("") /// 
    title("Register",size(vlarge)) /// 
    legend(order(2 "Female only" 4 "Male only" 6 "Info both") pos(4) col(1) region(lcolor(none) lwidth(none)) ring(0) size(large)) /// 
    ///text(-0.25 1.5 "*") ///
	text(0.25 -0.2 "{bf:c}", placement(nw) size(vlarge) ) /// 
    graphregion(color(white)) plotregion(color(white))	

graph save "${figure}/coefplot/ai_register.gph", replace


restore


graph combine "${figure}/coefplot/ai_willingtouse.gph" ///
              "${figure}/coefplot/ai_subscribe.gph" ///
              "${figure}/coefplot/ai_register.gph", ///
              rows(1) cols(3) ///
              title("", size(medlarge)) ///
			  note("Adjusted p-values using Holm-Bonferroni method for multiple comparisons", span size(medium)) ///
			  xsize(12) ysize(4)

graph export "${figure}/coefplot/figure4.png", replace width(7000) height(2000) 		


* ------------------------------------------------------------------------------
*                       fig.5
* ------------------------------------------------------------------------------

reg zee_ai_competitive c.Female_only##c.ai_skill_fairness  c.Male_only##c.ai_skill_fairness c.Both##c.ai_skill_fairness ai_premium_f_p ai_premium_m_p ai_competitive_pre $demo, r
estimates store zee_ai_competitive

reg zee_ai_employment_opp c.Female_only##c.ai_skill_fairness  c.Male_only##c.ai_skill_fairness c.Both##c.ai_skill_fairness ai_premium_f_p ai_premium_m_p ai_employment_opportunities_pre $demo, r
estimates store zee_ai_employment_opp

reg zee_ai_salary_opportunities c.Female_only##c.ai_skill_fairness  c.Male_only##c.ai_skill_fairness c.Both##c.ai_skill_fairness ai_premium_f_p ai_premium_m_p ai_salary_opportunities_pre $demo, r
estimates store zee_ai_salary_opportunities

reg zee_ai_willingness c.Female_only##c.ai_skill_fairness  c.Male_only##c.ai_skill_fairness c.Both##c.ai_skill_fairness ai_premium_f_p ai_premium_m_p ai_willingness_pre $demo, r
estimates store zee_ai_willingness

reg zee_ai_sub c.Female_only##c.ai_skill_fairness  c.Male_only##c.ai_skill_fairness c.Both##c.ai_skill_fairness ai_premium_f_p ai_premium_m_p ai_subscription_willingness_pre $demo, r
estimates store zee_ai_sub

reg register c.Female_only##c.ai_skill_fairness  c.Male_only##c.ai_skill_fairness c.Both##c.ai_skill_fairness ai_premium_f_p ai_premium_m_p $demo, r
estimates store register


* Generate coefficient plot for 1.Both#1.high_fair coefficients
coefplot ///
    (zee_ai_competitive, pstyle(p3) msymbol(O) rename(c.Both#c.ai_skill_fairness = "Makes me more competitive")) ///
    (zee_ai_employment_opp, pstyle(p3) msymbol(O) rename(c.Both#c.ai_skill_fairness = "Gives me more employment opportunities")) ///
    (zee_ai_salary_opportunities, pstyle(p3) msymbol(O) rename(c.Both#c.ai_skill_fairness = "Enables me to earn a higher salary")) ///
    (zee_ai_willingness, pstyle(p3) msymbol(O) rename(c.Both#c.ai_skill_fairness = "Willing to use AI")) ///
    (zee_ai_sub, pstyle(p3) msymbol(O) rename(c.Both#c.ai_skill_fairness = "Willing to subscribe paid AI tools")) ///
    (register, pstyle(p3) msymbol(O) rename(c.Both#c.ai_skill_fairness = "Register")), ///
    drop(_cons) keep(c.Both#c.ai_skill_fairness) ///
    ytitle("") xtitle("{it:Info both × Fairness concern}", margin(medium)) ///
    xline(0) ///
	xlabel(-0.2(0.2)0.6) ///
	legend(off) ///
    ylabel(, angle(0) labsize(small) nogrid) ///
    title("", size(medium)) ///
    graphregion(color(white)) ///
    pstyle(p3)
graph export "${figure}/coefplot/figure5.png", replace


* ------------------------------------------------------------------------------
*                       Extended Data Fig. 1
* ------------------------------------------------------------------------------
reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==1,r
lincom (_cons+Female_only)-(_cons)
lincom (_cons+Male_only)-(_cons)
lincom (_cons+Both)-(_cons)
lincom (_cons+Male_only)-(_cons+Female_only)
lincom (_cons+Both)-(_cons+Female_only)
lincom (_cons+Male_only)-(_cons+Both)

reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==0,r
lincom (_cons+Female_only)-(_cons)
lincom (_cons+Male_only)-(_cons)
lincom (_cons+Both)-(_cons)
lincom (_cons+Male_only)-(_cons+Female_only)
lincom (_cons+Both)-(_cons+Female_only)
lincom (_cons+Male_only)-(_cons+Both)

*********demean**************


quietly sum ai_premium_f, meanonly
gen demean_ai_premium_f = ai_premium_f - r(mean)
quietly sum ai_premium_m, meanonly
gen demean_ai_premium_m = ai_premium_m - r(mean)

foreach var in $demo {
    quietly sum `var', meanonly
    gen demean_`var' = `var' - r(mean)
}

quietly eststo Female: reg usdiff Female_only Male_only Both demean_ai_premium_f demean_ai_premium_m demean_* if female==1, r
quietly eststo Male: reg usdiff Female_only Male_only Both demean_ai_premium_f demean_ai_premium_m demean_* if female==0, r

reg usdiff Female_only Male_only Both demean_ai_premium_f demean_ai_premium_m demean_* if female==1, r
reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==1,r

reg usdiff Female_only Male_only Both demean_ai_premium_f demean_ai_premium_m demean_* if female==0, r
reg usdiff Female_only Male_only Both ai_premium_f ai_premium_m  $demo if female==0,r
preserve

* 提取女性回归系数
est restore Female
matrix female_coefs = e(b)
local control_f = female_coefs[1,colnumb(female_coefs,"_cons")]
local female_only_f = `control_f' + female_coefs[1,colnumb(female_coefs,"Female_only")]
local male_only_f = `control_f' + female_coefs[1,colnumb(female_coefs,"Male_only")]
local both_f = `control_f' + female_coefs[1,colnumb(female_coefs,"Both")]
di "Female Control: `control_f'"

* 提取男性回归系数
est restore Male
matrix male_coefs = e(b)
local control_m = male_coefs[1,colnumb(male_coefs,"_cons")]
local female_only_m = `control_m' + male_coefs[1,colnumb(male_coefs,"Female_only")]
local male_only_m = `control_m' + male_coefs[1,colnumb(male_coefs,"Male_only")]
local both_m = `control_m' + male_coefs[1,colnumb(male_coefs,"Both")]
di "Male Control: `control_m'"

* 创建绘图数据集
clear
set obs 8
gen group = ""
gen usdiff = .
gen gender = ""

replace group = "Control" in 1
replace usdiff = `control_f' in 1
replace gender = "Female" in 1

replace group = "Female_only" in 2
replace usdiff = `female_only_f' in 2
replace gender = "Female" in 2

replace group = "Male_only" in 3
replace usdiff = `male_only_f' in 3
replace gender = "Female" in 3

replace group = "Both" in 4
replace usdiff = `both_f' in 4
replace gender = "Female" in 4

replace group = "Control" in 5
replace usdiff = `control_m' in 5
replace gender = "Male" in 5

replace group = "Female_only" in 6
replace usdiff = `female_only_m' in 6
replace gender = "Male" in 6

replace group = "Male_only" in 7
replace usdiff = `male_only_m' in 7
replace gender = "Male" in 7

replace group = "Both" in 8
replace usdiff = `both_m' in 8
replace gender = "Male" in 8

* 确保 group 变量按正确顺序
gen group_order = 1 if group == "Control"
replace group_order = 2 if group == "Female_only"
replace group_order = 3 if group == "Male_only"
replace group_order = 4 if group == "Both"
sort gender group_order



* 绘制柱状图（性别之间无边框）
graph bar usdiff, over(group, sort(group_order)) over(gender, gap(200) label(labsize(small))) ///
    title("") ///
    ytitle("Perceived gender gap") ///
    ylabel(-4(2)8, labsize(small)) ///
    blabel(bar, format(%9.2f) size(small)) ///
    legend(off) ///
    bar(1, color(blue)) bar(2, color(red)) bar(3, color(green)) bar(4, color(purple)) ///
    graphregion(color(white) lcolor(none)) plotregion(lcolor(none)) ///
    ysize(4) xsize(6)

restore


quietly eststo Female: reg usdiff Female_only Male_only Both demean_ai_premium_f demean_ai_premium_m demean_* if female==1, r
quietly eststo Male: reg usdiff Female_only Male_only Both demean_ai_premium_f demean_ai_premium_m demean_* if female==0, r



preserve

* 提取女性回归系数和标准误差
est restore Female
matrix female_coefs = e(b)
matrix female_V = e(V)
local control_f = female_coefs[1,colnumb(female_coefs,"_cons")]
local se_control_f = sqrt(female_V[rownumb(female_V,"_cons"),colnumb(female_V,"_cons")])
local female_only_f = `control_f' + female_coefs[1,colnumb(female_coefs,"Female_only")]
local se_female_only_f = sqrt(female_V[rownumb(female_V,"Female_only"),colnumb(female_V,"Female_only")] + female_V[rownumb(female_V,"_cons"),colnumb(female_V,"_cons")] + 2*female_V[rownumb(female_V,"Female_only"),colnumb(female_V,"_cons")])
local male_only_f = `control_f' + female_coefs[1,colnumb(female_coefs,"Male_only")]
local se_male_only_f = sqrt(female_V[rownumb(female_V,"Male_only"),colnumb(female_V,"Male_only")] + female_V[rownumb(female_V,"_cons"),colnumb(female_V,"_cons")] + 2*female_V[rownumb(female_V,"Male_only"),colnumb(female_V,"_cons")])
local both_f = `control_f' + female_coefs[1,colnumb(female_coefs,"Both")]
local se_both_f = sqrt(female_V[rownumb(female_V,"Both"),colnumb(female_V,"Both")] + female_V[rownumb(female_V,"_cons"),colnumb(female_V,"_cons")] + 2*female_V[rownumb(female_V,"Both"),colnumb(female_V,"_cons")])
di "Female Control: `control_f'"

* 提取男性回归系数和标准误差
est restore Male
matrix male_coefs = e(b)
matrix male_V = e(V)
local control_m = male_coefs[1,colnumb(male_coefs,"_cons")]
local se_control_m = sqrt(male_V[rownumb(male_V,"_cons"),colnumb(male_V,"_cons")])
local female_only_m = `control_m' + male_coefs[1,colnumb(male_coefs,"Female_only")]
local se_female_only_m = sqrt(male_V[rownumb(male_V,"Female_only"),colnumb(male_V,"Female_only")] + male_V[rownumb(male_V,"_cons"),colnumb(male_V,"_cons")] + 2*male_V[rownumb(male_V,"Female_only"),colnumb(male_V,"_cons")])
local male_only_m = `control_m' + male_coefs[1,colnumb(male_coefs,"Male_only")]
local se_male_only_m = sqrt(male_V[rownumb(male_V,"Male_only"),colnumb(male_V,"Male_only")] + male_V[rownumb(male_V,"_cons"),colnumb(male_V,"_cons")] + 2*male_V[rownumb(male_V,"Male_only"),colnumb(male_V,"_cons")])
local both_m = `control_m' + male_coefs[1,colnumb(male_coefs,"Both")]
local se_both_m = sqrt(male_V[rownumb(male_V,"Both"),colnumb(male_V,"Both")] + male_V[rownumb(male_V,"_cons"),colnumb(male_V,"_cons")] + 2*male_V[rownumb(male_V,"Both"),colnumb(male_V,"_cons")])
di "Male Control: `control_m'"

* 创建绘图数据集
clear
set obs 8
gen group = ""
gen usdiff = .
gen gender = ""
gen se = .
gen ci_lower = .
gen ci_upper = .

replace group = "Control" in 1
replace usdiff = `control_f' in 1
replace se = `se_control_f' in 1
replace gender = "Female" in 1

replace group = "Female_only" in 2
replace usdiff = `female_only_f' in 2
replace se = `se_female_only_f' in 2
replace gender = "Female" in 2

replace group = "Male_only" in 3
replace usdiff = `male_only_f' in 3
replace se = `se_male_only_f' in 3
replace gender = "Female" in 3

replace group = "Both" in 4
replace usdiff = `both_f' in 4
replace se = `se_both_f' in 4
replace gender = "Female" in 4

replace group = "Control" in 5
replace usdiff = `control_m' in 5
replace se = `se_control_m' in 5
replace gender = "Male" in 5

replace group = "Female_only" in 6
replace usdiff = `female_only_m' in 6
replace se = `se_female_only_m' in 6
replace gender = "Male" in 6

replace group = "Male_only" in 7
replace usdiff = `male_only_m' in 7
replace se = `se_male_only_m' in 7
replace gender = "Male" in 7

replace group = "Both" in 8
replace usdiff = `both_m' in 8
replace se = `se_both_m' in 8
replace gender = "Male" in 8

* 计算 95% 置信区间
replace ci_lower = usdiff - 1.96 * se
replace ci_upper = usdiff + 1.96 * se

* 确保 group 变量按正确顺序
gen group_order = 1 if group == "Control"
replace group_order = 2 if group == "Female_only"
replace group_order = 3 if group == "Male_only"
replace group_order = 4 if group == "Both"
sort gender group_order

* 创建 bar 的 x 轴位置，考虑 gender 和 group 的分组
gen x_pos = .
replace x_pos = 1 if gender == "Female" & group == "Control"
replace x_pos = 2 if gender == "Female" & group == "Female_only"
replace x_pos = 3 if gender == "Female" & group == "Male_only"
replace x_pos = 4 if gender == "Female" & group == "Both"
replace x_pos = 6 if gender == "Male" & group == "Control"
replace x_pos = 7 if gender == "Male" & group == "Female_only"
replace x_pos = 8 if gender == "Male" & group == "Male_only"
replace x_pos = 9 if gender == "Male" & group == "Both"
	

graph twoway (bar usdiff x_pos if gender == "Female" & group == "Control", barwidth(0.4) color(forestgreen)) ///
             (bar usdiff x_pos if gender == "Female" & group == "Female_only", barwidth(0.4) color(magenta)) ///
             (bar usdiff x_pos if gender == "Female" & group == "Male_only", barwidth(0.4) color(navy)) ///
             (bar usdiff x_pos if gender == "Female" & group == "Both", barwidth(0.4) color(gold)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Control", barwidth(0.4) color(forestgreen)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Female_only", barwidth(0.4) color(magenta)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Male_only", barwidth(0.4) color(navy)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Both", barwidth(0.4) color(gold)) ///
             (scatteri -3 2 -3 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             (scatteri -3 2 -2.7 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -3 3 -2.7 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -3.7 2 -3.7 4, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             (scatteri -3.7 2 -3.4 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -3.7 4 -3.4 4, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)), ///
    xscale(range(0 10)) ///
    xlabel(1 "Control" 2 "Female only" 3 "Male only" 4 "Info both" 6 "Control" 7 "Female only" 8 "Male only" 9 "Info both", labsize(vsmall)) ///
    xtitle("") ///
    ytitle("Perceived gender gap") ///
    ylabel(-4(2)8, labsize(small)) ///
    text(8 2.5 "Female participants", size(medsmall) place(c)) ///
    text(8 7.5 "Male participants", size(medsmall) place(c)) ///
    text(-3.3 2.5 "***", size(medsmall) place(c)) ///
    text(-4 3 "***", size(medsmall) place(c)) ///
    legend(off) ///
    graphregion(color(white) lcolor(none)) plotregion(lcolor(none)) ///
    ysize(4) xsize(6) ///
    xline(5, lcolor(black) lpattern(dash)) /// // 分隔 Female 和 Male
    yline(-2 0 2 4 6, lcolor(gray%50) lpattern(solid) lwidth(vthin)) // 横轴网格线
    graph export "${figure}/coefplot/Extended_figure1.png", replace	
	
graph twoway (bar usdiff x_pos if gender == "Female" & group == "Control", barwidth(0.4) color(forestgreen)) ///
             (bar usdiff x_pos if gender == "Female" & group == "Female_only", barwidth(0.4) color(magenta)) ///
             (bar usdiff x_pos if gender == "Female" & group == "Male_only", barwidth(0.4) color(navy)) ///
             (bar usdiff x_pos if gender == "Female" & group == "Both", barwidth(0.4) color(gold)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Control", barwidth(0.4) color(forestgreen)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Female_only", barwidth(0.4) color(magenta)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Male_only", barwidth(0.4) color(navy)) ///
             (bar usdiff x_pos if gender == "Male" & group == "Both", barwidth(0.4) color(gold)) ///
             (scatteri -3 2 -3 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             (scatteri -3 2 -2.8 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -3 3 -2.8 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -3.6 2 -3.6 4, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             (scatteri -3.6 2 -3.4 2, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -3.6 4 -3.4 4, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) /// 
			 (scatteri -4.1 1 -4.1 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             (scatteri -4.1 1 -3.9 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -4.1 3 -3.9 3, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
			 (scatteri -4.5 1 -4.5 4, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             (scatteri -4.5 1 -4.3 1, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             (scatteri -4.5 4 -4.3 4, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)), ///  
			 ///(scatteri -1 6 -1 9, recast(line) lcolor(black) lpattern(solid) lwidth(vthin))  ///  // 主横线
             ///(scatteri -1 6 -0.8 6, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)) ///  
             ///(scatteri -1 9 -0.8 9, recast(line) lcolor(black) lpattern(solid) lwidth(vthin)), ///
    xscale(range(0 10)) ///
    xlabel(1 "Control" 2 "Female only" 3 "Male only" 4 "Info both" 6 "Control" 7 "Female only" 8 "Male only" 9 "Info both", labsize(vsmall)) ///
    xtitle("") ///
    ytitle("Perceived gender gap") ///
    ylabel(-4(2)8, labsize(small)) ///
    text(8 2.5 "Female participants", size(small) place(c)) ///
    text(8 7.5 "Male participants", size(small) place(c)) ///
    text(-3.2 2.5 "**", size(small) place(c)) ///
    text(-3.8 3 "***", size(small) place(c)) ///
	///text(-1.2 7.5 "*", size(small) place(c)) ///
	text(-4.3 2 "**", size(small) place(c)) ///
	text(-4.7 2.5 "***", size(small) place(c)) ///
    legend(off) ///
    graphregion(color(white) lcolor(none)) plotregion(lcolor(none)) ///
    ysize(4) xsize(6) ///
    xline(5, lcolor(black) lpattern(dash)) /// // 分隔 Female 和 Male
    yline(-2 0 2 4 6, lcolor(gray%50) lpattern(solid) lwidth(vthin)) // 横轴网格线
    graph export "${figure}/coefplot/Extended_figure1b.png", replace		
	
restore

